typedef struct _LINE
{
	int end;
	int weight;
	struct _LINE* next;
}LINE;

typedef struct _VERTEX
{
	int start;
	int number;
	LINE* neighbor;
	struct _VERTEX* next;
}VERTEX;

typedef struct _GRAPH
{
	int count;
	VERTEX* head;
}GRAPH;

VERTEX* create_new_vertex(int start)
{
	VERTEX* pVertex = (VERTEX*)malloc(sizeof(VERTEX));

	pVertex->start = start;
	pVertex->number = 0;
	pVertex->neighbor = NULL;
	pVertex->next = NULL;
	return pVertex;
}

LINE* create_new_line(int end, int weight)
{
	LINE* pLine = (LINE*)malloc(sizeof(LINE));

	pLine->end = end;
	pLine->weight = weight;
	pLine->next = NULL;
	return pLine;
}

VERTEX* create_new_vertex_for_graph(int start, int end, int weight)
{
	VERTEX* pVertex = create_new_vertex(start);

	pVertex->neighbor = create_new_line(end, weight);
	return pVertex;
}

GRAPH* create_new_graph(int start, int end, int weight)
{
	GRAPH* pGraph = (GRAPH*)malloc(sizeof(GRAPH));
	pGraph->count = 1;
	pGraph->head = create_new_vertex_for_graph(start, end, weight);
	return pGraph;
}

VERTEX* find_vertex_in_graph(VERTEX* pVertex, int start)
{
	if(NULL == pVertex)
		return NULL;

	while(pVertex){
		if(start == pVertex->start)
			return pVertex;
		pVertex = pVertex->next;
	}
	return NULL;
}

LINE* find_line_in_graph(LINE* pLine, int end)
{
	if(NULL == pLine)
		return NULL;

	while(pLine){
		if(end == pLine->end)
			return pLine;
		pLine = pLine->next;
	}
	return NULL;
}

